package com.ntanh.mealplanner.main.planner;

import android.app.Activity;
import android.content.Context;
import android.graphics.Typeface;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.ntanh.mealplanner.R;

import java.util.List;

/**
 * Created by Anh Nguyen on 3/2/2015.
 */
public class MealListAdapter extends ArrayAdapter {

    private Context context;
    private List<String> listItems;
    private Integer layoutResourceID;

    public MealListAdapter(Context context, int layoutResourceID, List<String> listItems) {
        super(context, layoutResourceID, listItems);
        this.context = context;
        this.listItems = listItems;
        this.layoutResourceID = layoutResourceID;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View view = convertView;

        if (view == null) {
            LayoutInflater inflater = ((Activity) context).getLayoutInflater();
            view = inflater.inflate(layoutResourceID, parent, false);
        }
        TextView itemName = (TextView) view.findViewById(R.id.lblMealItem);
        String text = listItems.get(position);
        if(!text.startsWith("    ")){
            itemName.setTypeface(null, Typeface.BOLD);
        }
        itemName.setText(listItems.get(position));

        return view;
    }
}
